package com.wanmait.wanmarecruit.manageController;

import com.github.pagehelper.PageInfo;
import com.wanmait.wanmarecruit.entity.Company;
import com.wanmait.wanmarecruit.service.CompanyService;
import com.wanmait.wanmarecruit.service.ConfigService;
import com.wanmait.wanmarecruit.util.AjaxResult;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("manage")
public class ManageAuditCompanyController {

    @Resource
    private CompanyService companyService;
    @Resource
    private ConfigService configService;

    @RequestMapping("getAllAuditCompaniesByPageNum")
    public AjaxResult getAllAuditCompaniesByPageNum(Integer pageNum)
    {
        if (pageNum==null)
        {
            pageNum=1;
        }
        Integer pageSize = Integer.parseInt(configService.getByKeyword("company_audit_paging_size").getConfigValue());
        PageInfo<Company> companies = companyService.selectAuditCompanies(pageNum,pageSize);
        return AjaxResult.success("查询成功").put("companies",companies);
    }

    @GetMapping("passOneCompany")
    public AjaxResult passOneCompany(Integer id)
    {
        companyService.updateEnableCompany(id);
        return AjaxResult.success("审核成功");
    }

    @GetMapping("deleteOneCompany")
    public AjaxResult deleteOneCompany(Integer id)
    {
        companyService.deleteOneCompany(id);
        return AjaxResult.success("删除成功");
    }
}
